define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'record/refund/index',
                    add_url: 'record/refund/add',
                    // edit_url: 'record/refund/edit',
                    del_url: 'record/refund/del',
                    multi_url: 'record/refund/multi',
                    table: 'applyrefund',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport:false,
                showToggle: false,
                showColumns: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        // {field: 'openid', title: __('Openid')},
                        {field: 'refundsn', title: __('Refundsn'),operate:'LIKE'},
                        {field: 'price', title: __('Price'), operate:false},
                        {field: 'refundtime', title: __('Refundtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'member.id', title: __('Member.id')},
                        // {field: 'id', title: __('Id')},
                        // {field: 'openid', title: __('Openid')},
                        // {field: 'refundsn', title: __('Refundsn')},
                        // {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        // {field: 'refundtime', title: __('Refundtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'member.id', title: __('Member.id')},
                        // {field: 'member.openid', title: __('Member.openid')},
                        // {field: 'member.avatar_image', title: __('Member.avatar_image'), formatter: Table.api.formatter.image},
                        // {field: 'member.username', title: __('Member.username')},
                        // {field: 'member.nickname', title: __('Member.nickname')},
                        // {field: 'member.mobile', title: __('Member.mobile')},
                        // {field: 'member.agentid', title: __('Member.agentid')},
                        // {field: 'member.identity', title: __('Member.identity')},
                        // {field: 'member.membersn', title: __('Member.membersn')},
                        // {field: 'member.p_id', title: __('Member.p_id')},
                        // {field: 'member.credit', title: __('Member.credit'), operate:'BETWEEN'},
                        // {field: 'member.creditcode', title: __('Member.creditcode')},
                        // {field: 'member.bindtime', title: __('Member.bindtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'member.periodtime', title: __('Member.periodtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'member.createtime', title: __('Member.createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});